<template>
	<view v-if="modelValue" >
		<my-main  title="选择客户"  isBack isNotDep :table="table" @search="getTbody" @infoFun="infoFun" :close="close">
			<template #tableTbody="{ tbody }">
				<up-cell-group>
					<up-cell  :title="item.ClientName" :isLink="true" :key="index" v-for="(item,index) in tbody" @click="click(item)"></up-cell>
				</up-cell-group>
			</template>
		</my-main>
	</view>
</template>

<script lang="uts" setup>
//公共状态
import { useVue  } from '@/utils/useVue.uts'
const { reactive, ref,app,Token,onMounted,watch,http,goToPage,getPrevPageQuery,useAttrs } = useVue()
interface Props {
	toPage?:string,
	modelValue?:boolean,
}
const props = withDefaults(defineProps<Props>(), {

})
const emit = defineEmits(['click','close','update:modelValue'])
const close=()=>{
	emit('update:modelValue',false)
	emit('close')
}
// 所有未声明的属性都会进入 $attrs
const attrs = useAttrs()
// 合并所有属性（显式 props + attrs）
const allProps = {
  ...props,
  ...attrs
}
// 表单数据
const table:any = reactive({
	loading: false,//数据加载
	padding:0,
	search:{
		PageLimit: 30,
		PageIndex: 1,
		Count: 0,
		ClientName: "",
		ClientCode: "",
		CustomerType:"",//客户类型
		SalerName:"",
	},
	searchSet:{
		searchKey:'ClientName',
		searchLabel:'客户名称',
	},
	tbody:[],
})
const click=(row:any)=>{
	emit('click',row)
}
//搜索
const getTbody = (scrollSet?:any) => {
	table.loading=true
	http.request({
		url: 'api/CustomerMan/QueryClientsInfos',
		data: table.search,
		isNotToken: true,
		success: (res : any) => {
			table.tbody.push(...res.children)
			table.search.Count = res.Count
			_scrollSet()
		},
		fail:()=>{
			_scrollSet()
		}
	})
	function _scrollSet(){
		table.loading=false
		if(scrollSet){
			scrollSet.triggered=false
		}
	}
}

onMounted(() => {
	getTbody()
})
</script>

<style scoped lang="scss"></style>
